23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
28 vector
<long long> ugly
;
31 priority_queue
<long long, vector
<long long>, greater
<long long> > q
;
34 while (ugly
.size() < 1500) {
35 long long v
= q
.top();
37 if (ugly
.back() != v
) {
40 if (v
% 3 != 0 and v
% 5 != 0) {
49 // for (int i = 0; i < 100; ++i) {
50 // printf("ugly[%d] = %lld\n", i, ugly[i]);
52 printf("The 1500'th ugly number is %lld.\n", ugly
[1499]);